package ai.zixing.pool;

import lombok.extern.slf4j.Slf4j;

import java.util.concurrent.ThreadFactory;
import java.util.concurrent.atomic.AtomicInteger;

/**
 * @author zixing
 */
@Slf4j
public class MyThreadFactory implements ThreadFactory {
    private final AtomicInteger threadId = new AtomicInteger(1);

    /**
     * 自定义线程工厂
     */
    @Override
    public Thread newThread(Runnable r) {
        log.info("自定义线程工厂");
        return new Thread(r, "MyThread-" + threadId.getAndDecrement()  * 10);
    }
}
